package com.ktgj.service.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.service.domain.ContractLinkVipchannelPrice;
import com.ktgj.service.service.IContractLinkVipchannelPriceService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 合同VIP通道服务价格Controller
 * 
 * @author ruoyi
 * @date 2021-09-03
 */
@ControllerAdvice
@RestController
@RequestMapping("/viplinkprice")
public class ContractLinkVipchannelPriceController extends BaseController
{
    @Autowired
    private IContractLinkVipchannelPriceService contractLinkVipchannelPriceService;

    /**
     * 查询合同VIP通道服务价格列表
     */
    @PreAuthorize(hasPermi = "service:price:list")
    @GetMapping("/list")
    public TableDataInfo list(ContractLinkVipchannelPrice contractLinkVipchannelPrice)
    {
        startPage();
        List<ContractLinkVipchannelPrice> list = contractLinkVipchannelPriceService.selectContractLinkVipchannelPriceList(contractLinkVipchannelPrice);
        return getDataTable(list);
    }

    /**
     * 导出合同VIP通道服务价格列表
     */
    @PreAuthorize(hasPermi = "service:price:export")
    @Log(title = "合同VIP通道服务价格", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ContractLinkVipchannelPrice contractLinkVipchannelPrice) throws IOException
    {
        List<ContractLinkVipchannelPrice> list = contractLinkVipchannelPriceService.selectContractLinkVipchannelPriceList(contractLinkVipchannelPrice);
        ExcelUtil<ContractLinkVipchannelPrice> util = new ExcelUtil<ContractLinkVipchannelPrice>(ContractLinkVipchannelPrice.class);
        util.exportExcel(response, list, "合同VIP通道服务价格数据");
    }

    /**
     * 获取合同VIP通道服务价格详细信息
     */
    @PreAuthorize(hasPermi = "service:price:query")
    @GetMapping(value = "/{contractVipchannelpriceId}")
    public AjaxResult getInfo(@PathVariable("contractVipchannelpriceId") Long contractVipchannelpriceId)
    {
        return AjaxResult.success(contractLinkVipchannelPriceService.selectContractLinkVipchannelPriceById(contractVipchannelpriceId));
    }

    /**
     * 新增合同VIP通道服务价格*/
    @PreAuthorize(hasPermi = "service:price:add")
    @Log(title = "合同VIP通道服务价格", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ContractLinkVipchannelPrice contractLinkVipchannelPrice)
    {
        return toAjax(contractLinkVipchannelPriceService.insertContractLinkVipchannelPrice(contractLinkVipchannelPrice));
    }

    /**
     * 修改合同VIP通道服务价格*/
    @PreAuthorize(hasPermi = "service:price:edit")
    @Log(title = "合同VIP通道服务价格", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ContractLinkVipchannelPrice contractLinkVipchannelPrice)
    {
        return toAjax(contractLinkVipchannelPriceService.updateContractLinkVipchannelPrice(contractLinkVipchannelPrice));
    }

    /**
     * 删除合同VIP通道服务价格*/
    @PreAuthorize(hasPermi = "service:price:remove")
    @Log(title = "合同VIP通道服务价格", businessType = BusinessType.DELETE)
	@DeleteMapping("/{contractVipchannelpriceIds}")
    public AjaxResult remove(@PathVariable Long[] contractVipchannelpriceIds)
    {
        return toAjax(contractLinkVipchannelPriceService.deleteContractLinkVipchannelPriceByIds(contractVipchannelpriceIds));
    }
}
